package com.ruoyi.information.controller.back;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.information.domain.back.CloudClassroomProjectMainBack;
import com.ruoyi.information.service.back.ICloudClassroomProjectMainBackService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 云课堂专辑Controller
 * 后台
 * @author ruoyi
 * @date 2023-04-28
 */
@RestController
@RequestMapping("/projectBack")
public class CloudClassroomProjectMainBackController extends BaseController
{
    @Autowired
    private ICloudClassroomProjectMainBackService cloudClassroomProjectMainService;

    /**
     * 查询云课堂专辑列表
     */
    @RequiresPermissions("information:project:list")
    @GetMapping("/list")
    public TableDataInfo list(CloudClassroomProjectMainBack cloudClassroomProjectMain)
    {
        startPage();
        List<CloudClassroomProjectMainBack> list = cloudClassroomProjectMainService.selectCloudClassroomProjectMainList(cloudClassroomProjectMain);
        return getDataTable(list);
    }

    /**
     * 查询云课堂列表查专辑列表
     */
    @GetMapping("/listAll")
    public AjaxResult listAll(CloudClassroomProjectMainBack cloudClassroomProjectMain)
    {
        List<CloudClassroomProjectMainBack> list = cloudClassroomProjectMainService.selectCloudClassroomProjectMainList(cloudClassroomProjectMain);
        return AjaxResult.success(list);
    }

    /**
     * 导出云课堂专辑列表
     */
    @RequiresPermissions("information:project:export")
    @Log(title = "云课堂专辑", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CloudClassroomProjectMainBack cloudClassroomProjectMain)
    {
        List<CloudClassroomProjectMainBack> list = cloudClassroomProjectMainService.selectCloudClassroomProjectMainList(cloudClassroomProjectMain);
        ExcelUtil<CloudClassroomProjectMainBack> util = new ExcelUtil<CloudClassroomProjectMainBack>(CloudClassroomProjectMainBack.class);
        util.exportExcel(response, list, "云课堂专辑数据");
    }

    /**
     * 获取云课堂专辑详细信息
     */
    @RequiresPermissions("information:project:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cloudClassroomProjectMainService.selectCloudClassroomProjectMainById(id));
    }

    /**
     * 新增云课堂专辑
     */
    @RequiresPermissions("information:project:add")
    @Log(title = "云课堂专辑", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CloudClassroomProjectMainBack cloudClassroomProjectMain)
    {
        return toAjax(cloudClassroomProjectMainService.insertCloudClassroomProjectMain(cloudClassroomProjectMain));
    }

    /**
     * 修改云课堂专辑
     */
    @RequiresPermissions("information:project:edit")
    @Log(title = "云课堂专辑", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CloudClassroomProjectMainBack cloudClassroomProjectMain)
    {
        return toAjax(cloudClassroomProjectMainService.updateCloudClassroomProjectMain(cloudClassroomProjectMain));
    }

    /**
     * 删除云课堂专辑
     */
    @RequiresPermissions("information:project:remove")
    @Log(title = "云课堂专辑", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cloudClassroomProjectMainService.deleteCloudClassroomProjectMainByIds(ids));
    }
}
